package com.guigu.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.VendorService;
import com.guigu.mapper.VendorMapper;
import com.guigu.pojo.FrontUser2;
import com.guigu.pojo.Businesses;
import com.guigu.pojo.Vendor;
import com.guigu.vo.Pojo;
import com.guigu.vo.VendorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VendorServiceImpl extends ServiceImpl<VendorMapper, Vendor> implements VendorService {
    @Autowired
    private VendorMapper vendorMapper;

    @Override
    public Pojo<FrontUser2> getPage(int pageNum, int pageSize, VendorVo vo) {
        //设置分页
        PageHelper.startPage(pageNum,pageSize);
        //查询
        List<FrontUser2> frontUser2s = vendorMapper.selectAll(vo, pageNum, pageSize);
        //封装分页数据
        PageInfo<FrontUser2> frontUser2PageInfo = new PageInfo<>(frontUser2s);
        //封装到pojo中
        Pojo<FrontUser2> frontUser2Pojo = new Pojo<>();
        //设置分页数据
        frontUser2Pojo.setRows(frontUser2PageInfo.getList());
        frontUser2Pojo.setTotal(frontUser2PageInfo.getTotal());
        return frontUser2Pojo;
    }


    //liyongchao


    @Override
    public Vendor One(int id) {
        Vendor one = vendorMapper.One(id);
        return one;
    }

    @Override
    public void getOne(QueryWrapper<Businesses> queryWrapper) {

    }

    @Override
    public Vendor One1(int uerId) {
        Vendor vendor = vendorMapper.One1(uerId);
        return vendor;
    }
}